max_n:int = 2000+5

a:str='\0'+input().strip()
b:str='\0'+input().strip()

dp:list[list[int]] = [[max_n]*(len(b)+1) for _ in range(len(a)+1)]

# print(dp)

for i in range(0,len(a)+1):
    dp[i][0]=i

for i in range(0,len(b)+1):
    dp[0][i]=i

for i in range(1,len(a)):
    for j in range(1,len(b)):
        if a[i]==b[j]:
            dp[i][j] = dp[i-1][j-1]
            continue
        dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1

print(dp[len(a)-1][len(b)-1])